package com.yellowpage.wf.service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.yellowpage.white.common.PageRender;
import com.yellowpage.white.dao.QueryAssistantSQL;
import com.yellowpage.white.service.BaseServiceImpl;
import com.yellowpage.wf.dao.ContextInstanceDao;
import com.yellowpage.wf.data.ContextInstance;

public class ContextInstanceServiceImpl extends BaseServiceImpl implements ContextInstanceService {
	  private ContextInstanceDao contextInstanceDao;
	
	  public void setContextInstanceDao(ContextInstanceDao contextInstanceDao) {
		  this.contextInstanceDao = contextInstanceDao;
	  }
	
	
	  /* White generate Method */ 
	  public List<Map> getContextVersion(Long instanceId,Long contextId){
			String sql = "select max(wci.version) as version from wf_context_instance wci where " +
					" wci.workflow_instance_id = "+instanceId.toString()+
					" and wci.context_id = "+contextId.toString();

			QueryAssistantSQL sqlAssistant = baseDao.newQueryAssistantSQL(sql);
			List<Map> resultList = this.baseDao.query(sqlAssistant, new HashMap());
			return resultList;
		}
	  public void saveContextInstance(ContextInstance contextInstance)
	  {
		  contextInstanceDao.save(contextInstance);
	  }
}	